Add standalone single-module profile smoke test - #548
Conversation
| # Diagnostic codes that only ever fire because a required contract binding | ||
| # (e.g. a database the module consumes) wasn't supplied -- expected when a | ||
| # module is exercised standalone rather than wired up in a real profile. | ||
| _EXPECTED_UNBOUND_CODES = {"E030", "E041", "E042"} |
There was a problem hiding this comment.
The allowlist comment calls E030/E041/E042 "unresolved contract binding" codes. E030 is not a contract-binding code. In cli/validator.py, validate_module_configs emits E030 for config-schema violations, and it fires here because the test passes config: {}. validate_contract_bindings emits E041/E042. The allowlist works, but the wrong label invites a future regression: someone who trims it to "contract-binding codes only" breaks the test for every module with required config.
| # Diagnostic codes that only ever fire because a required contract binding | |
| # (e.g. a database the module consumes) wasn't supplied -- expected when a | |
| # module is exercised standalone rather than wired up in a real profile. | |
| _EXPECTED_UNBOUND_CODES = {"E030", "E041", "E042"} | |
| # Codes expected when a module runs standalone (no sibling modules, no config | |
| # supplied) instead of wired into a real profile: | |
| # E030 - config-schema violation (fires because we pass config: {}, so any | |
| # module with required config fields reports them missing) | |
| # E041 - a required `consumes` binding could not be resolved (no producer | |
| # module exists in the standalone profile) | |
| # E042 - contract kind mismatch on a consumed binding | |
| _EXPECTED_UNBOUND_CODES = {"E030", "E041", "E042"} |
| module_def = yaml.safe_load(module_yaml.read_text(encoding="utf-8")) | ||
| version = module_def.get("metadata", {}).get("version", "0.1.0") | ||
|
|
||
| profile = { | ||
| "apiVersion": "cds/v1alpha1", | ||
| "kind": "Profile", | ||
| "metadata": {"name": "standalone-smoke", "environment": "local"}, | ||
| "spec": { | ||
| "runtime": {"type": "docker-compose"}, | ||
| "modules": [ | ||
| { | ||
| "id": "under-test", | ||
| "source": source, | ||
| "version": version, | ||
| "enabled": True, | ||
| "config": {}, | ||
| } | ||
| ], | ||
| }, | ||
| } |
There was a problem hiding this comment.
version is read from metadata.version and written into the profile instance, but validate_profile never consults it. load_module_instances reads source, enabled, config, dependsOn, id only, and resolve_module_file resolves by source + CDS_MODULE_PATH. The field is dead. Drop it. Also, if metadata.version: is explicit null, .get("version", "0.1.0") returns None and puts "version": None in the profile (harmless only because it is ignored).
| module_def = yaml.safe_load(module_yaml.read_text(encoding="utf-8")) | |
| version = module_def.get("metadata", {}).get("version", "0.1.0") | |
| profile = { | |
| "apiVersion": "cds/v1alpha1", | |
| "kind": "Profile", | |
| "metadata": {"name": "standalone-smoke", "environment": "local"}, | |
| "spec": { | |
| "runtime": {"type": "docker-compose"}, | |
| "modules": [ | |
| { | |
| "id": "under-test", | |
| "source": source, | |
| "version": version, | |
| "enabled": True, | |
| "config": {}, | |
| } | |
| ], | |
| }, | |
| } | |
| module_def = yaml.safe_load(module_yaml.read_text(encoding="utf-8")) | |
| profile = { | |
| "apiVersion": "cds/v1alpha1", | |
| "kind": "Profile", | |
| "metadata": {"name": "standalone-smoke", "environment": "local"}, | |
| "spec": { | |
| "runtime": {"type": "docker-compose"}, | |
| "modules": [ | |
| { | |
| "id": "under-test", | |
| "source": source, | |
| "enabled": True, | |
| "config": {}, | |
| } | |
| ], | |
| }, | |
| } |
Summary
Adds
tests/test_standalone_module_profile.py, a generic smoke test thatdiscovers every
module.yamlundermodules/(andmodules-experimental/,if present) and validates it in isolation.
For each module, the test builds a throwaway single-module
Profilereferencing only that module — no sibling modules, no
dependsOn, nocontract bindings supplied by another module — and runs it through
cli.validator.validate_profile.Modules with a required
consumesentry (e.g. Superset'smetadataDatabase, Dagster'srun-storage) can't resolve that bindingstandalone, so
E030/E041/E042diagnostics are expected and allowlisted.Any other diagnostic code (
E001,E010,E011,E020,E021,E022,...) fails the test, since it indicates a genuine problem with the module's
own definition — invalid YAML, a schema violation in
module.yamlitself,or a malformed
consumes/providesentry.Testing
python -m unittest tests.test_standalone_module_profile -vpython -m unittest discover -s tests -p "test_*.py" -v(full suite, 556 tests, all pass)make lint